<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of proveedor_model
 *
 * @author Neil
 */
class proveedor_model extends CI_Model {

    public function list_proveedor($cod) {
        $sql = "call sp_listarProveedor(?)";
        $query = $this->db->query($sql, $cod);
        if ($query->num_rows() > 0) {
            foreach ($query->result() as $fila) :
                $data[] = $fila;
            endforeach;
        }else {
            $data = null;
        }
        return $data;
    }

    public function IU_Proveedor($params, $cod) {
        $sql = "call sp_IU_Proveedor(?,?,?,?,?,@id)";
        $this->db->query("select $cod into @id");
        $this->db->query($sql, $params);
        $query = $this->db->query("select @id as codProv");
        return $query->row()->codProv;
    }

    public function buscarxRUC($ruc) {
        $sql = "call sp_buscarProveedor(?)";
        $query = $this->db->query($sql, $ruc);
        return $query->row();
    }

}

?>
